import React, { Component, Fragment } from 'react';
import { connect } from 'dva';
import { Button, Card, Divider } from 'antd';
import router from 'umi/router';
import DescriptionList from '@/components/DescriptionList';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';

const { Description } = DescriptionList;
const ButtonGroup = Button.Group;

@connect(({ batchFileimportTask, loading }) => ({
  batchFileimportTask,
  loading: loading.effects['batchFileimportTask/loadDomain'],
}))
class BatchFileimportTaskProfile extends Component {
  componentDidMount() {
    const {
      dispatch,
      match: { params },
    } = this.props;
    dispatch({
      type: 'batchFileimportTask/loadDomain',
      payload: params.pid,
    });
  }

  goback = () => {
    // history.back();
    router.goBack();
  };

  render() {
    const {
      batchFileimportTask: { domain },
    } = this.props;
    const action = (
      <Fragment>
        <ButtonGroup>
          <Button icon="rollback" onClick={this.goback}>
            返回
          </Button>
        </ButtonGroup>
      </Fragment>
    );

    return (
      <PageHeaderWrapper title="批任务管理器" action={action}>
        <Card bordered={false}>
          <DescriptionList size="large" title="基础信息" style={{ marginBottom: 32 }}>
            <Description term="任务ID">{domain.taskId}</Description>
            <Description term="任务名称">{domain.taskName}</Description>
            <Description term="任务类型">{domain.taskType}</Description>
            <Description term="操作类型">{domain.operType}</Description>
            <Description term="操作人账号">{domain.operator}</Description>
            <Description term="操作人ID">{domain.operatorId}</Description>
            <Description term="操作人名称">{domain.operatorName}</Description>
            <Description term="业务对象">{domain.bsBo}</Description>
            <Description term="总数">{domain.totalRec}</Description>
            <Description term="成功数">{domain.succRec}</Description>
            <Description term="失败数">{domain.failRec}</Description>
            <Description term="失败日志">{domain.failLog}</Description>
            <Description term="处理状态">{domain.procStateName}</Description>
            <Description term="处理方式">{domain.procWayName}</Description>
            <Description term="消耗时间（秒）">{domain.costTime}</Description>
            <Description term="创建时间">{domain.createDate}</Description>
            <Description term="处理服务器IP">{domain.serverIp}</Description>
            <Description term="开始执行时间">{domain.beginTime}</Description>
            <Description term="完成执行时间">{domain.finishTime}</Description>
            <Description term="处理文件">{domain.proceFileName}</Description>
          </DescriptionList>
          <Divider style={{ marginBottom: 32 }} />
        </Card>
      </PageHeaderWrapper>
    );
  }
}
export default BatchFileimportTaskProfile;
